<div>
  <nz-collapseset>
    <nz-collapse [nzTitle]="panels.name" [nzActive]="panels.active" [nzDisabled]="panels.disabled">
      <form nz-form>
        <div nz-form-item nz-row style="margin-bottom: 12px">
          <div nz-form-label nz-col [nzSpan]="3">
            <label>单位名称</label>
          </div>
          <div nz-form-control nz-col [nzSpan]="4">
            <nz-input [(ngModel)]="trainingPlanDetail.partyName" name="partyName">
            </nz-input>
          </div>

          <div nz-form-label nz-col [nzSpan]="3">
            <label>单位管理人员</label>
          </div>
          <div nz-form-control nz-col [nzSpan]="4">
            <nz-input style="width:200px;" [(ngModel)]="trainingPlanDetail.unitManageUser"
                      name="unitManageUser"></nz-input>
          </div>


          <div nz-form-label nz-col [nzSpan]="3">
            <label>计划状态</label>
          </div>
          <div nz-form-control nz-col [nzSpan]="4">
            <nz-select style="width: 150px;" nzAllowClear [nzPlaceHolder]="'请选择'"
                       [(ngModel)]="trainingPlanDetail.planStatus"
                       [nzShowSearch]="true" name="checkState">
              <nz-option *ngFor="let option of planStatus" [nzLabel]="option.label"
                         [nzValue]="option.value"></nz-option>
            </nz-select>
          </div>
        </div>


        <div>
          <div nz-form-item nz-row>
            <div nz-form-label nz-col [nzSpan]="3">
              <label>实施时间</label>
            </div>
            <div nz-form-control nz-col [nzSpan]="7">
              <nz-datepicker [nzSize]="'large'" [nzFormat]="'YYYY-MM-DD'" name="startDate" [nzPlaceHolder]="'开始日期'"
                             [(ngModel)]="trainingPlanDetail.startDate"></nz-datepicker>
              至
              <nz-datepicker [nzSize]="'large'" [nzFormat]="'YYYY-MM-DD'" name="endDate" [nzPlaceHolder]="'结束日期'"
                             [(ngModel)]="trainingPlanDetail.endDate"></nz-datepicker>
            </div>

            <button nz-button [nzSize]="'large'" [nzType]="'primary'" (click)="query()">查询</button>
          </div>
        </div>

      </form>
    </nz-collapse>
  </nz-collapseset>


  <nz-table #nzTable [nzDataSource]="dataList" nzSize="middle" [nzBordered]="true" [nzIsPagination]="false" (nzDataChange)="displayDataChange($event)">
    <thead nz-thead>
    <tr>
      <th nz-th [nzCheckbox]="true">
        <label nz-checkbox [(ngModel)]="allChecked" [nzIndeterminate]="indeterminate" (ngModelChange)="checkAll($event)">
        </label>
      </th>
      <th nz-th>
        <span>计划名称</span>
      </th>
      <th nz-th>
        <span>单位名称</span>
      </th>
      <th nz-th>
        <span>单位类型</span>
      </th>
      <th nz-th>
        <span>牵头单位</span>
      </th>
      <th nz-th>
        <span>计划实施时间</span>
      </th>
      <th nz-th>
        <span>单位安全管理人员</span>
      </th>
      <th nz-th>
        <span>计划状态</span>
      </th>
      <th nz-th>
        <span>培训材料</span>
      </th>
      <th nz-th>
        <span>培训现场照片</span>
      </th>
      <th nz-th>
        <span>培训签到表</span>
      </th>
      <th nz-th>
        <span>考核汇总表</span>
      </th>

    </tr>
    </thead>
    <tbody nz-tbody>
    <tr nz-tbody-tr *ngFor="let data of dataList">
      <td nz-td [nzCheckbox]="true">
        <label nz-checkbox [nzDisabled]="data.disabled" [(ngModel)]="data.checked" (ngModelChange)="refreshStatus($event)">
        </label>
      </td>
      <td nz-td>{{data.planName}}</td>
      <td nz-td>{{data.partyName}}</td>
      <td nz-td>{{data.partyType | constantTransfer : partyTypes}}</td>
      <td nz-td>{{data.leadUnit}}</td>
      <td nz-td>{{(data.startDate | dateFormat)}} 至 {{(data.endDate | dateFormat)}}</td>
      <td nz-td>{{data.unitManageUser}}</td>
      <td nz-td>{{data.planStatus | constantTransfer : planStatus}}</td>
      <td nz-td>
        <span>
            <nz-popover [nzTitle]="'请选择'" [nzPlacement]="'bottom'" [nzTrigger]="'click'">
                <button nz-button [nzSize]="'small'" [nzType]="'primary'" nz-popover>导出</button>
                <ng-template #nzTemplate>
                    <div>
                        <button nz-button [nzSize]="'small'" (click)="downloadFile(data,1)">培训资料</button>
                    </div>
                    <div style="margin-top:10px">
                        <button nz-button [nzSize]="'small'" (click)="downloadFile(data,2)">培训签到表</button>
                    </div>
                    <div style="margin-top:10px">
                        <button nz-button [nzSize]="'small'" (click)="downloadFile(data,3)">培训试卷</button>
                    </div>
                    <div style="margin-top:10px">
                        <button nz-button [nzSize]="'small'" (click)="downloadFile(data,4)">考核汇总表</button>
                    </div>
                </ng-template>
            </nz-popover>
        </span>
      </td>
      <td nz-td><button nz-button [nzSize]="'small'"  [nzType]="'primary'" (click)="uploadFile(data,1)">上传</button></td>
      <td nz-td><button nz-button [nzSize]="'small'" [nzType]="'primary'" (click)="uploadFile(data,2)">上传</button></td>
      <td nz-td><button nz-button [nzSize]="'small'" [nzType]="'primary'" (click)="uploadFile(data,3)">上传</button></td>
    </tr>
    </tbody>
  </nz-table>

  <nz-pagination [nzPageIndex]="trainingPlanDetail.currentPage" nzShowTotal [nzTotal]="total" nzShowSizeChanger
                 (nzPageSizeChange)="nzPageSizeChange($event)" (nzPageIndexChange)="nzPageIndexChange($event)"
                 (nzPageIndexClickChange)="nzPageIndexClickChange($event)" [nzPageSize]="trainingPlanDetail.pageSize"></nz-pagination>


  <!--添加现场图片 -->
  <!--添加培训签到表 -->
  <!--考核汇总表 -->
  <nz-modal [nzVisible]="isVisible" [nzTitle]="'文件上传'" [nzOkText]="'确定'" [nzCancelText]="'取消'" [nzContent]="modalContent"
            (nzOnCancel)="isVisible=false" (nzOnOk)="isVisible=false">
    <ng-template #modalContent>
      <!--
            <nz-spin [nzTip]="'正在上传请等待...'" [nzSpinning]="nzSpinning1">
      -->
      <nz-upload *ngIf="uploadType==1" nzAction="{{config.IP+config.API.upload}}" nzListType="picture-card"
                 [(nzFileList)]="trainingPhotoFileList" [nzShowButton]="true" [nzRemove]="nzRemoveFile"
                 (nzChange)="nzChangeFile($event)">
        <i class="anticon anticon-plus"></i>
        <div class="ant-upload-text">上传培训现场图片</div>
      </nz-upload>

      <nz-upload *ngIf="uploadType==2" nzAction="{{config.IP+config.API.upload}}" nzListType="text"
                 [(nzFileList)]="checkInTableFileList" [nzShowButton]="true" [nzRemove]="nzRemoveFile"
                 (nzChange)="uploadChange($event)">
        <button nz-button>
          <i class="anticon anticon-upload"></i>
          <span>上传培训签到表</span>
        </button>
      </nz-upload>

      <nz-upload *ngIf="uploadType==3" nzAction="{{config.IP+config.API.upload}}" nzListType="text"
                 [(nzFileList)]="summaryStatementFileList" [nzShowButton]="true" [nzRemove]="nzRemoveFile"
                 (nzChange)="uploadChange($event)">
        <button nz-button>
          <i class="anticon anticon-upload"></i>
          <span>上传考核汇总表</span>
        </button>
      </nz-upload>


      <div style="text-align: center;margin-top: 30px;">
        <button nz-button [nzSize]="'large'" (click)="updateUpload()" [nzType]="'primary'">确定上传</button>
      </div>
      <!--
            </nz-spin>
      -->
    </ng-template>
  </nz-modal>

  <!--添加页面 -->
  <ng-template #title>
    <span>{{modelTitle}}</span>
  </ng-template>
  <ng-template #content>
    <trainingPlan-add-page *ngIf="modal==0"></trainingPlan-add-page>
    <trainingPlan-update-page *ngIf="modal==1"></trainingPlan-update-page>
  </ng-template>
  <ng-template #footer>
    <div>
    </div>
  </ng-template>
</div>
